﻿using System;
using System.Collections.Generic;
using PagedList;
using CodeCamp.Models.Shared;

namespace CodeCamp.Models.EventMgmt
{
    public interface ISiteUserSearchFiler
    {
        Nullable<int> EventId { get; }

        Nullable<DateTime> ActiveSince { get; }
        string FirstName { get; }
        bool IsEventPresenter { get; }
        string LastName { get; }
    }

    public class SiteUserSearchViewModel : ISiteUserSearchFiler
    {
        public Nullable<int> EventId { get; set; }

        public Nullable<DateTime> ActiveSince { get; set; }
        public string EventShortName { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public bool IsEventPresenter { get; set; }

        public string ClearButton { get; set; }
        public Nullable<DateTime> FilterTime { get; set; }
        public Nullable<long> FilterTimeTicks
        {
            get
            {
                long? noTicks = null;
                return FilterTime.HasValue ? FilterTime.Value.Ticks : noTicks;
            }
            set
            {
                if (value.HasValue)
                    FilterTime = new DateTime(value.Value);
                else
                    FilterTime = null;
            }
        }
        public Nullable<int> Page { get; set; }
        public Nullable<int> RowsPerPage { get; set; }
        public string SearchButton { get; set; }
        public IPagedList<SiteUserListItemViewModel> SearchResults { get; set; }

        public string UTCOffsetMinutes { get; set; }
        public Nullable<int> UTCAdjustMinutes
        {
            get
            {
                return TimeAdjust.UTCAdjustMinutes(UTCOffsetMinutes);
            }
        }
    }
}